03. Classes Versus Objects
Title
Classes Versus Objects
ND079 JAVA C1 L2 A02 Lesson Overview- Classes Vs Objects
A class is like a blueprint for a kind of object. The class defines the state and behavior that an object of that class will have.
A single class can instantiate (or create) multiple objects of the same type. So, objects can also be referred to as instances of the class. Each instance of a class is unique, though they all follow the same blueprint defined in the class.
ND079 JAVA C1 L2 A05 Classes Vs Objects
When we instantiate (or create) objects from that class, they will all have the states and behaviors defined in the class. Each object is considered an instance of the class. Like the dogs in the example, each object can have its own unique state, but all objects will share the same set of behaviors.
Class versus Object
QUIZ QUESTION::
For each of the statements below, does it better describe a class or an object?
ANSWER CHOICES:
Description |
Class or Object? |
---|---|
Can essentially be used as a blueprint. |
|
Is a specific instance. |
|
Can have a customized state. |
|
Defines the behaviors that instances can have. |
SOLUTION:
Description |
Class or Object? |
---|---|
Is a specific instance. |
|
Can have a customized state. |
|
Can essentially be used as a blueprint. |
|
Defines the behaviors that instances can have. |
|
Is a specific instance. |
|
Can have a customized state. |
|
Can essentially be used as a blueprint. |
|
Defines the behaviors that instances can have. |